﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace WebAppIdentity.Controllers
{
	/// <summary>
	/// 受参数签名保护的公共API
	/// </summary>
	[ApiController]
	[AllowAnonymous]
	[Route("[controller]")]
	public class SignProtectedAPIController : ControllerBase
	{
		public class PostApiDemo
		{
			public int Id { get; set; }
			public string? Name { get; set; }
		}

		[HttpPost("PostApi")]
		public async Task<string?> PostApi(PostApiDemo m)
		{
			await Task.CompletedTask;
			return m.Name;
		}

		[HttpGet("List")]
		public Task<List<PostApiDemo>> List(int id, string name)
		{
			var list = new List<PostApiDemo>();
			for (int i = 0; i < 10; i++)
			{
				list.Add(new PostApiDemo { Id = id, Name = name });
			}
			return Task.FromResult(list);
		}
	}
}
